var t = require("../../../@babel/runtime/helpers/defineProperty"), a = getApp();

Page({
    data: {
        statistical: {},
        popover_text: "全部",
        actions: [ {
            text: "全部"
        } ],
        info: {},
        status: 0,
        activeName: 0,
        dataList: [],
        titleArr: [ {
            name: "广告审核",
            code: "audit",
            isPopover: !1
        } ],
        isLoadMore: !0,
        showTabs: !1,
        isShowPopover: !1
    },
    onLoad: function(t) {
        this.init(), this.getData();
    },
    init: function() {
        this.setData({
            showTabs: !1,
            activeName: 0,
            dataList: [ {
                isLoadMore: !0,
                page: 1,
                total_page: 0,
                url: "plugin.ad-serving.frontend.advertisers.index.advertisingCheck",
                list: []
            } ],
            isLoadMore: !0
        }), this.handleClick();
    },
    getData: function() {
        var t = this, e = "";
        e += a.getNetAddresss("plugin.ad-serving.frontend.advertisers.index.memberInfo"), 
        a._getNetWork({
            url: e,
            success: function(a) {
                var e = a.data;
                if (1 == e.result) {
                    var i = e.data.plugins_status, s = t.data.titleArr, o = t.data.dataList;
                    i.video_share && (s.push({
                        name: "视频订单",
                        code: "video",
                        isPopover: !1
                    }), o.push({
                        isLoadMore: !0,
                        page: 1,
                        total_page: 0,
                        list: [],
                        url: "plugin.ad-serving.frontend.advertisers.index.getOrderInfo"
                    })), i.room && (s.push({
                        name: "直播订单",
                        code: "live",
                        isPopover: !1
                    }), o.push({
                        isLoadMore: !0,
                        page: 1,
                        total_page: 0,
                        list: [],
                        url: "plugin.ad-serving.frontend.advertisers.index.getOrderInfo"
                    })), t.setData({
                        info: e.data.info,
                        titleArr: s,
                        dataList: o,
                        showTabs: !0
                    });
                } else wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    onClick: function(t) {
        this.setData({
            popover_text: "全部",
            activeName: t.detail.index
        }), this.handleClick();
    },
    handleClick: function(e) {
        var i = this;
        this.changeActions();
        var s = {};
        console.log("1111111111111111111111", e), e ? (s.status = Number(e), this.status = e) : this.status = 0, 
        "video" == this.data.titleArr[this.data.activeName].code && (s.put_in_type = 2);
        var o = a.getNetAddresss(this.data.dataList[this.data.activeName].url);
        a._getNetWork({
            url: o,
            data: s,
            success: function(a) {
                var e, s = a.data;
                1 == s.result ? i.setData((e = {
                    statistical: s.data.statistical ? s.data.statistical : {}
                }, t(e, "dataList[" + i.data.activeName + "].isLoadMore", !0), t(e, "dataList[" + i.data.activeName + "].total_page", s.data.list.last_page), 
                t(e, "dataList[" + i.data.activeName + "].list", s.data.list.data), e)) : wx.showToast({
                    title: s.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    changePopover: function() {
        this.setData({
            isShowPopover: !this.data.isShowPopover
        });
    },
    clickPopover: function(t) {
        this.handleClick(t.currentTarget.dataset.id), this.changePopover(), this.setData({
            popover_text: t.currentTarget.dataset.name
        });
    },
    changeActions: function() {
        var t = [];
        t = 0 == this.data.activeName ? [ {
            text: "全部",
            status: ""
        }, {
            text: "待审核",
            status: "0"
        }, {
            text: "通过",
            status: "1"
        }, {
            text: "驳回",
            status: "-1"
        } ] : [ {
            text: "全部",
            status: ""
        }, {
            text: "投放中",
            status: "1"
        }, {
            text: "下架",
            status: "0"
        } ], this.setData({
            actions: t
        });
    },
    gotoUrl: function(t) {
        var a = t.currentTarget.dataset;
        "advertisingRelease" == a.tag ? wx.navigateTo({
            url: "/packageH/Advertising/advertisingRelease/advertisingRelease"
        }) : "advertisingAdDetails" == a.tag && wx.navigateTo({
            url: "/packageH/Advertising/advertisingAdDetails/advertisingAdDetails?id=" + a.id
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.dataList[this.data.activeName].isLoadMore ? this._getMoreData() : console.log("没有更多数据");
    },
    _getMoreData: function() {
        var e = this;
        if (this.setData(t({}, "dataList[" + e.data.activeName + "].isLoadMore", !1)), !(this.data.dataList[this.data.activeName].page >= this.data.dataList[this.data.activeName].total_page)) {
            var i = {};
            i.status = Number(this.status), "video" == this.data.titleArr[this.data.activeName].code && (i.put_in_type = 2), 
            this.data.dataList[this.data.activeName].page = this.data.dataList[this.data.activeName].page + 1;
            var s = a.getNetAddresss(this.data.dataList[this.data.activeName].url);
            s += "&page=" + this.data.dataList[this.data.activeName].page, a._getNetWork({
                url: s,
                data: i,
                success: function(a) {
                    var i = a.data;
                    if (1 == i.result) {
                        var s, o = i.data.list;
                        e.setData((t(s = {}, "dataList[" + e.data.activeName + "].isLoadMore", !0), t(s, "dataList[" + e.data.activeName + "].list", e.data.dataList[e.data.activeName].list.concat(o.data)), 
                        s));
                    } else {
                        var d;
                        e.setData((t(d = {}, "dataList[" + e.data.activeName + "].isLoadMore", !1), t(d, "dataList[" + e.data.activeName + "].page", e.data.dataList[e.data.activeName].page - 1), 
                        d));
                    }
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    onShareAppMessage: function() {}
});